#ifndef CSE168_AARECT_H_INCLUDED
#define CSE168_AARECT_H_INCLUDED

#include "Vector3.h"
#include "Object.h"

class AARect : public Object
{
public:
	AARect();
	AARect(Vector3 c1, Vector3 c2, int axis, Vector3 N);
	virtual ~AARect();

	void setC1(const Vector3& v)    {m_c1 = v;}
	void setC2(const Vector3& v)    {m_c2 = v;}
	void setN(const Vector3& v)     {m_norm = v;}
	void setAARect(Vector3 c1, Vector3 c2, int axis, Vector3 N) {
		m_c1 = c1;
		m_c2 = c2;
		m_min = Vector3(std::min(m_c1.x, m_c2.x)-epsilon, std::min(m_c1.y, m_c2.y)-epsilon, std::min(m_c1.z, m_c2.z)-epsilon);
		m_max = Vector3(std::max(m_c1.x, m_c2.x)+epsilon, std::max(m_c1.y, m_c2.y)+epsilon, std::max(m_c1.z, m_c2.z)+epsilon);
		m_axis = axis;
		m_norm = N;
	}

    virtual void renderGL();
	virtual void preCalc();
    virtual bool intersect(HitInfo& result, const Ray& ray,
                           float tMin = 0.0f, float tMax = MIRO_TMAX);

protected:
	Vector3 m_c1;
	Vector3 m_c2;
	//Vector3 m_min;
	//Vector3 m_max;
	Vector3 m_norm;
	int m_axis;
};

#endif // CSE168_AARECT_H_INCLUDED
